Kurs Komputerowy S
System Symboliczny
Mathematica

Obliczenia symboliczne

Definiowanie zmiennych

zmienna = wartosc
Set[zmienna,wartosc]

a1=5

b1=a1^4

a1=15

b1

b2=a2^4

a2=5
b2

a2=15
b2

a1+b1

Set[c1,a1^3]

c1

Clear[a2,b2]

a2

b2=a2^4

a2=5

b2

a2=15

b2

zmienna := wartosc
SetDelayed[zmienna,wartosc]

a3=5

b3:=a3^4

b3

a3=15

b3

zmienna = .
Unset[zmienna]

Quit

a=5
b=34
c=8

a=.

a+b

?a

Clear[a]

?a

Unset[c]

c

Podstawianie zmiennych:
/.    (*  ReplaceAll[]  *)
//.   (* ReplaceRepeated[]   *)

b2=a2^4

b2/.a2->5

a2

a=2x+7

x=2
a

x=3
a

x

x=.

x

a/.x->2
a/.x->3

x

a=.
b=.

x^2+a x/.x->a

x^2+a x//.{x->a,a->b}

x^2+4x//.{x->a,a->x}

Funkcje i wielomiany

BesselI[n, z]
BesselJ[n,z]
BesselK[n,z]
BesselY[n,z]
BernoulliB[n,x]
...

BesselI[0,1.]

Plot[BesselI[1,x],{x,-3,3}]

BesselI[1,2.0]

Plot[BesselJ[1,x],{x,-3,3}]

BernoulliB[2,x]

ChebyshevT[n, x]
ChebyshevU[n,x]
HermiteH[n,x]
LaguerreL[n,a,x]
LegendreP[n,x]
...

ChebyshevT[4,x]

ChebyshevU[4,x]

HermiteH[4,x]

LaguerreL[4,p,x]

LegendreP[4,x]

Dzialania na liczbach

Permutations[lista]
Binomial[n,m]
Multinomial[n1,n2,...]
FactorInteger[liczba]
GCD[l1,l2]
LCM[l1,l2]

a=Permutations[{1,2,3,4,5,6,7}];

a[[5]]

7!

Binomial[4,2]   (* n!/(m!(n-m)!) *)

Multinomial[2,3,4]   (* (n1+n2+...)!/(n1!n2!...) *)

2^4*5^3*9*7^2

FactorInteger[%]

GCD[60,45]

LCM[60,45]

Zaokraglanie liczb:
Ceiling[liczba]
Floor[liczba]
Round[liczba]

Ceiling[2.4]
Ceiling[-2.4]

Floor[2.4]
Floor[-2.4]

Round[2.4]
Round[-2.4]

Dzialania na wyrazeniach algebraicznych

Numerator[wyr]
Denominator[wyr]
ExpandNumerator[wyr]
ExpandDenominator[wyr]
Together[wyr]
Apart[wyr]

e=(x-1)^2(2+x)/((1+x)(x-3)^2)

Numerator[e]

Denominator[e]

ExpandNumerator[e]

ExpandDenominator[e]

e1=(x+2)/((x^2-9))
e2=(x-4)/(x+3)

e1+e2

Together[e1+e2]

ExpandDenominator[Together[e1+e2]]

(x^2+1)/(x-1)

Apart[(x^2+1)/(x-1)]

Dzialania na wielomianach

Expand[wyr]
Factor[wyr]
Simplify[wyr]
FullSimplify[wyr]
ExpandAll[wyr]
PowerExpand[wyr]
TrigExpand[wyr]
ComplexExpand[wyr]

(2+x)^10

Expand[%]+1

Factor[%]

(x^2+2x+1)/(x+1)

Simplify[%]

e

Expand[e]

Expand[%]

ExpandAll[e]

q=Sqrt[x y]

Expand[q]

ExpandAll[q]

PowerExpand[q]

Expand[Sin[2x]]

TrigExpand[Sin[2x]]

Simplify[%]

Expand[Sin[x+I y]]

ComplexExpand[Sin[x+I y]]

Simplify[%]

?*Expand*

Collect[wiel, zm]
Coefficient[wiel,wyr]
CoefficientList[wiel,zm]
Exponent[wiel,wyr]

c=Expand[(2x+3y+2)^3*2x(4y-2)^2]

Collect[c,x]

Collect[c,y]

Coefficient[c,x^5]

Coefficient[c,x y^2]

CoefficientList[c,x]

CoefficientList[c,y]

Exponent[c,y]

Exponent[c,y^2]

PolynomialQuotient[w1,w2,zm]
PolynomialRemainder[w1,w2,zm]

w1=x^5-4x^4+3x^3-2x+4
w2=x^2-5x+5

pq=PolynomialQuotient[w1,w2,x]

pr=PolynomialRemainder[w1,w2,x]

pq*w2+pr-w1

Simplify[(pq*w2+pr)-w1]

Operatory logiczne

Porownywanie:
==   (*  Equal[]  *)
<     (*  Less[]  *)
<=   (*  LessEqual[]  *)
>     (*  Greater[]  *)
>=   (*  GreaterEqual[]  *)
!=    (*  Unequal[]  *)

2==4

3<5

Unequal[4,5]

y==4

&&    (* And[]  *)
 ||       (*  Or[]  *)

3==5 &&5>4

3==5||5>4

Rozwiazywanie rownan

Solve[rownanie, zmienna]
Reduce[rownanie,zmienna]

x=.

Solve[x==4,x]

Solve[x^2+5x-14==0,x]

eq=x^2+6x+5==0
Solve[eq,x]

eqp=x^2 +6p x+5==0

s=Solve[eqp,x]

s[[1]]

s[[1,1]]

s[[1,1,2]]

s1=Solve[s[[1,1,2]]==s[[2,1,2]],p]

e1=eqp/.s1

Solve[e1[[1]],x]

Solve[e1[[2]],x]

a=.

Solve[a x+b==0,x]

Reduce[a x+b==0,x]

Solve[Sin[x]==1/2,x]

Reduce[Sin[x]==1/2,x]

Solve[{rownanie1, rownanie2,...},{zmienna1, zmienna2,...}]
Reduce[{rownanie1, rownanie2,...},{zmienna1, zmienna2,...}]

(Piecewise[{{2x, +5y-8=0}, {4x, -3y=12}}])

Solve[{2x+5y-8==0,4x-3y==12},{x,y}]

Reduce[{2x+5y-8==0,4x-3y==12},{x,y}]

(Piecewise[{{2(x^2), +5y-8=0}, {4x, -3y=12}}])

Solve[{2x^2+5y-8==0,4x-3y==12},{x,y}]

Reduce[{2x^2+5y-8==0,4x-3y==12},{x,y}]

Eliminate[{rownanie1, rownanie2, ...}, zmienna]
Roots[rownanie_wielomianowe,zmienna]

s=Eliminate[{2x+5y-4z==6,5x-2y+4z==12,x+y-z==6},z]

Roots[x^6-6x^5+4x^3+x^2-5==0,x]//N

Granice i ciagi

Limit[funkcja, zmienna -> wartosc]
Sum[wyrazenie,{zmienna, w_pocz,w_kon}]
Product[wyrazenie,{zmienna,w_pocz,w_kon}]

Limit[x^2+1,x->1]

Limit[2x^2/(x+2),x->-2]

Limit[2x^2/(x+2),x->-2,Direction->1]

Limit[2x^2/(x+2),x->-2,Direction->-1]

Options[Limit]

Sum[1/x^2,{x,1.5,10.8}]

Sum[1/x^2,{x,1,Infinity}]

Sum[1/x,{x,1,10000}]//N

Product[1/x,{x,1,10}]

Product[1/x,{x,1,Infinity}]

Rachunek rozniczkowy i calkowy

D[funkcja, zmienna]
D[funkcja,zm1,zm2,...]
D[funkcja,{zmienna,n}]

Solve[x^2+x+1==0,x]

?*Integrate*

D[x^2,x]

D[x^n,x]

D[Sin[x],x]

D[Cos[x],x]

D[Exp[x],x]

D[x^2,{x,2}]

D[x^2,x,x]

f=x^2+y^2-5x y
D[f,x]
D[f,y]

D[f,x,y]
D[f,y,x]

y=.

Dt[2x^2z+5y x,x]

Integrate[funkcja, zmienna]
Integrate[funkcja,{zmienna,w_pocz,w_kon}]

f=2x+10
ff=D[f,x]

Integrate[ff,x]

Integrate[ff,{x,2,5}]

∫Sin[x]\[DifferentialD]x

Integrate[Cos[x],x]

Integrate[Sin[x],{x,-Pi/2,0}]

Sin[Pi/2]-Sin[-Pi/2]

Integrate[x^2+4x,x]

Transformacje

LaplaceTransform[funkcja, t, s]
FourierTransform[funkcja,t,ω]
ZTransform[funkcja,n,z]
...

s=.

lf=LaplaceTransform[t^4Sin[t],t,s]

Plot[{t^4Sin[t],lf/.s->t},{t,-4,4}]

ft=FourierTransform[Exp[-t^2] Sin[t],t,ω]

Plot[{Exp[-t^2]Sin[t],Im[ft]/.ω->t},{t,-4,4}]

zf=ZTransform[n^2 2^(-n),n,z]

Plot[{n^2 2^(-n),zf/.z->n},{n,-3,3}]

Szeregi

Series[funkcja,{zmienna,x0,stopien}]
Normal[szereg]

f1=Series[Sin[x],{x,0,5}]

Normal[f1]

f2=Series[Sin[x],{x,Pi/2,5}]

f1=Normal[f1]
f2=Normal[f2]

Plot[{Sin[x],f1,f2},{x,-2,4}]

Rownania rozniczkowe

DSolve[rownanie, funkcja, zmienna]
DSolve[{rown1,rown2,...},{f1, f2,...},zmienna]

DSolve[y'[x]==Sin[x],y[x],x]

DSolve[{y'[x]==Sin[x],y[0]==2},y[x],x]

DSolve[y'[x]+2y[x]==Cos[x],y[x],x]

Systemy liczenia

BaseForm[liczba, podstawa]
podstawa^^liczba

BaseForm[103422,16]

BaseForm[103422,37]

9^^1010